package com.log4jviewer.filters;

/**
 * The structure which stores the values of filter item
 * 
 * @author <a href="mailto:rd.ryly@gmail.com">Ruslan Diachenko</a>
 */

public class FilterItemModel {

    private LogicOperand logicOperand;

    private FieldType fieldType;

    // Include or Exclude logs with matching pattern.
    private boolean include;

    // String of matching pattern.
    private String pattern;

    // Enable or Disable item in the rule.
    private boolean enabled;

    public LogicOperand getLogicOperand() {
        return logicOperand;
    }

    public void setLogicOperand(final LogicOperand logicOperand) {
        this.logicOperand = logicOperand;
    }

    public FieldType getFieldType() {
        return fieldType;
    }

    public void setFieldType(final FieldType fieldType) {
        this.fieldType = fieldType;
    }

    /**
     * @return If logs are include or exclude with specified pattern (true|false)
     */
    public boolean isInclude() {
        return include;
    }

    /**
     * @param include
     *            - If logs are include or exclude with specified pattern (true|false)
     */
    public void setInclude(final boolean include) {
        this.include = include;
    }

    /**
     * @return Matching pattern
     */
    public String getPattern() {
        return pattern;
    }

    /**
     * @param pattern
     *            - Matching pattern
     */
    public void setPattern(final String pattern) {
        this.pattern = pattern;
    }

    /**
     * @return If the Item is enabled or disabled in the rule (true|false)
     */
    public boolean isEnabled() {
        return enabled;
    }

    /**
     * @param enabled
     *            - If the Item is enabled or disabled in the rule (true|false)
     */
    public void setEnabled(final boolean enabled) {
        this.enabled = enabled;
    }

    public static enum LogicOperand {
        AND("and"),
        OR("or");

        private String value;

        private LogicOperand(final String vaule) {
            this.value = vaule;
        }

        public String getValue() {
            return value;
        }
    }

    public static enum FieldType {
        LEVEL("level"),
        MESSAGE("message"),
        CATEGORY("category"),
        LINE("line"),
        DATE("date"),
        NDC("ndc"),
        THROWABLE("throwable");

        private String value;

        private FieldType(final String vaule) {
            this.value = vaule;
        }

        public String getValue() {
            return value;
        }
    }
}
